﻿@page "/Wms/SaleReturnInWarehouseDetail/Details"
@using nERP.ViewModel.Wms.SaleReturnInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
            <Display @bind-Value="@Model.Entity.Seq" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.SaleReturnInWarehouseId" ShowLabel="true" Lookup="AllSaleReturnInWarehouses" />
            <Display @bind-Value="@Model.Entity.SaleReturnInWarehouseDetailCode" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.SaleReturnId" ShowLabel="true" Lookup="AllSaleReturns" />
            <Display @bind-Value="@Model.Entity.SaleReturnDetailId" ShowLabel="true" Lookup="AllSaleReturnDetails" />
            <Display @bind-Value="@Model.Entity.WarehouseId" ShowLabel="true" Lookup="AllWarehouses" />
            <Display @bind-Value="@Model.Entity.GoodsId" ShowLabel="true" Lookup="AllGoodss" />
            <Display @bind-Value="@Model.Entity.GoodsName" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.GoodsSpec" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.GoodsUnit" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.ReturnNumber" ShowLabel="true" FormatString="0.##" />
            <Display @bind-Value="@Model.Entity.Status" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Remark" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.CreateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.UpdateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.CreateBy" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.UpdateBy" ShowLabel="true" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SaleReturnInWarehouseDetailVM Model = new SaleReturnInWarehouseDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Wms/SaleReturnInWarehouseDetail/Edit", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    private List<SelectedItem> AllSaleReturnInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturns = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturnDetails = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {


        AllSaleReturnInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnInWarehouses");
        AllSaleReturnInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllSaleReturns = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturns");
        AllSaleReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllSaleReturnDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnDetails");
        AllSaleReturnDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<SaleReturnInWarehouseDetailVM>($"/api/Wms/SaleReturnInWarehouseDetail/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
